package com.example.spring.demo.controller;

import com.example.spring.demo.common.model.req.MessageDTO;
import com.example.spring.demo.entity.Message;
import com.example.spring.demo.service.MessageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2024/12/29 10:33
 **/
@Slf4j
@RestController
@RequestMapping("/api/message")
@RequiredArgsConstructor
public class MessageController {

    private final MessageService messageService;
    @GetMapping("/id/{id}")
    public Message getMessageById(@PathVariable String id) {
        return messageService.getMessageById(id);
    }

    @GetMapping("/name/{messageName}")
    public Message getMessageByName(@PathVariable String messageName) {
        return messageService.getMessageByName(messageName);
    }

    @PostMapping("/save")
    public void saveMessage(@RequestBody MessageDTO messageDTO) {
        messageService.saveMessage(messageDTO);
    }


    /*
    getMessage()
    saveMessage()
    removeMessage()
     */
}
